# -*- coding:utf-8 -*-
from pydantic import Field
from sqlalchemy import Column, Integer, String, DateTime, Enum, DECIMAL, Float, TEXT
from core.curd import Base, TimestampMixin
from pydantic import BaseModel

class SysOrg(Base, TimestampMixin):
    """
    测试表
    """
    __tablename__ = 'sys_org'

    id = Column(Integer, nullable=False, autoincrement=True, primary_key=True, comment='id')
    pid = Column(Integer, comment='上级ID')
    code = Column(String(16), comment='机构代码')
    name = Column(String(50), comment='机构名称')
    sort = Column(Integer, comment='排序')
    tenant_id = Column(Integer, comment='租户ID')
    version = Column(Integer, comment='版本号')
    deleted = Column(Integer, comment='删除标识  0：正常   1：已删除')
    creator = Column(Integer, comment='创建者')
    updater = Column(Integer, comment='更新者')
    status = Column(Integer, comment='状态  0：停用   1：正常')


class CreateSysOrg(BaseModel):
    pid: int = Field(comment='上级ID')
    code: str = Field(comment='机构名称', min_length=2, max_length=8, pattern='^[a-zA-Z0]{2,8}%')
    name: str = Field(comment='机构名称', max_length=50)
    sort: int = Field(comment='排序')
    status: int = Field(comment='状态  0：停用   1：正常')


class UpdateSysOrg(BaseModel):
    id: int = Field(comment='id')
    pid: int = Field(comment='上级ID')
    code: str = Field(comment='机构名称', max_length=16)
    name: str = Field(comment='机构名称', max_length=50)
    sort: int = Field(comment='排序')
    status: int = Field(comment='状态  0：停用   1：正常')
